package srx.open.com.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

import srx.open.com.R;
import srx.open.com.bean.CoursePublish;
import srx.open.com.utils.DataBaseHelper;
import srx.open.com.widgets.CircleImageView;

/**
 * 我的课程adpter.
 * 
 * @author hailongqiu 356752238@qq.com
 *
 */
public class MyCourseAdpter extends BaseAdapter {

	LayoutInflater mInflater;
	List<CoursePublish> mPubList;
	DataBaseHelper mDataBaseHelper;
	
	public MyCourseAdpter(final Context context,
			final List<CoursePublish> pubList,
			final DataBaseHelper dataBaseHelper) {
		mInflater = LayoutInflater.from(context);
		mDataBaseHelper = dataBaseHelper;
		mPubList = pubList;
	}

	public void setPubList(List<CoursePublish> pubList) {
		mPubList = pubList;
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		return 50; //mPubList != null ? mPubList.size() : 0;
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, final View convertView, final ViewGroup parent) {
		final MyViewHolder holder;
		View row = convertView;
		if (row == null) {
			row = mInflater.inflate(R.layout.listitem_my_pub_course, parent,
					false);
			holder = new MyViewHolder(row);
			row.setTag(holder);
		} else {
			holder = (MyViewHolder) row.getTag();
		}
		 
		return row;
	}
	
	private static class MyViewHolder {
		public CircleImageView bg_iv;

		public MyViewHolder(View v) {
			bg_iv = (CircleImageView) v.findViewById(R.id.bg_iv);
		}
	}
	
}
